Use type cast instead of method call#549
Conversation
simonschaufi
commented
Mar 17, 2026
- replace strval with (string)
- replace intval with (int)
- replace floatval with (float)
- replace strval with (string) - replace intval with (int) - replace floatval with (float)
|
Why? |
|
The php extended plugin from phpstorm suggest it and also several stackoverflow questions https://stackoverflow.com/a/546850 |
|
The code coverage of this library is very low. I don't think we should be merging any code at all without a strong reason. |
|
I'm confident that nothing breaks as this is no functional change but purely a code quality change. I would totally understand if some refactoring would be done but in this case not at all. |
|
For me personally I find (int) harder to read than intval() and I doubt there are real performance gains to be had by using type casts in this library. |
|
I have a different opinion about readability. I actually like casts because they have different color in IDEs than function calls. Especially on nested function calls it's much easier to read in my opinion: intval(strtotime($variable));
(int)strtotime($variable); |
|
I personally like casting better than using the functions. But personal preference is also the only reason I see here, since there are no real functional gains in my opinion. I Suggest we vote: @simonschaufi 👍 Other opinions? |
|
I think a more important question is: |
|
code quality is as important as new features. If you neglect code quality, the code will start rotting over time. Same with your body. Do fitness to keep your body healthy, otherwise you will become sick at some point. |
|
Just give me 👍 or 👎 please |